<template>
  <div>
    年龄
    <input type="text" v-model="age">
    <button @click="onOk">ok</button>
  </div>
</template>

<script>
import eventBus from '../event-bus';
export default {
  data () {
    return {
      age: eventBus.person.age,
    };
  },
  methods: {
    onOk () {
      eventBus.$emit('改年龄', this.age);
      eventBus.$emit('改名字', 'hello world');
      // this.$nextTick的回调函数是在所有组件全部更新完成触发/运行的
      this.$nextTick(() => {
        console.log(document.getElementById('name').innerText);
      });
    },
  },
}
</script>

<style scoped>

</style>